package pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters
{
	import pl.ydp.components.mathcell.mathrecognizer.characters.Character;
	import pl.ydp.components.mathcell.mathrecognizer.geometry.classification.PrimitiveType;
	import pl.ydp.components.mathcell.mathrecognizer.model.PrimitivesRelation;
	import pl.ydp.components.mathcell.mathrecognizer.model.RelationDescription;
	import pl.ydp.components.mathcell.mathrecognizer.model.RelationDescriptorType;
	import pl.ydp.components.mathcell.mathrecognizer.model.ShapeModel;
	import pl.ydp.components.mathcell.mathrecognizer.model.descriptors.AngleDescriptor;
	import pl.ydp.components.mathcell.mathrecognizer.model.descriptors.ConnectionsDescriptor;
	import pl.ydp.components.mathcell.mathrecognizer.model.descriptors.LocationDescriptor;
	import pl.ydp.components.mathcell.mathrecognizer.model.descriptors.ObjectDescriptor;
	import pl.ydp.components.mathcell.mathrecognizer.model.descriptors.SizeDescriptor;
	import pl.ydp.components.mathcell.mathrecognizer.model.presets.PrimitivePresets;
	public class MB_ch_1
	{
		
		public static const MODELS_COUNT:Number = 1;
		
		//---------------------------------------------------
		
		public static function getModels():Array{
			
			var oneShapeModels:Array = new Array();
			
			oneShapeModels.push(getModel0());
			oneShapeModels.push(getModel1());	
			oneShapeModels.push(getModel2());	
			oneShapeModels.push(getModel3());	
			oneShapeModels.push(getModel4());		
			
			return oneShapeModels;
		}
		
		//---------------------------------------------------
		
		private static function getModel0():ShapeModel{
			var one:ShapeModel;
			var name:String = "MB_1STRGHT";
			var one_prim:Array = new Array();
			var one_ref:Array = new Array();
			var one_rel:Array = new Array();
			
			one_prim.push(PrimitiveType.LINE2);
			
			one_ref.push(0,PrimitivePresets.ABS_UPPER_HALF);
			
			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10, ObjectDescriptor.END_NORTHERN)));
			
			one = new ShapeModel(Character.ONE, one_prim, one_ref, one_rel, new Array(), name);
			
			return one;				
		}
		
		//---------------------------------------------------
		
		private static function getModel1():ShapeModel{
			var one:ShapeModel;
			var name:String = "MB_1CLSSC";
			var one_prim:Array = new Array();
			var one_ref:Array = new Array();
			var one_rel:Array = new Array();
			
			one_prim.push(PrimitiveType.LINE2 | PrimitiveType.LINE3,  PrimitiveType.LINE2);
			
			one_ref.push(0,1,PrimitivePresets.RLT_FULL);
			
			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.CONNECTION, ConnectionsDescriptor.EXIST, 10, 
															ObjectDescriptor.END_EASTERN, ObjectDescriptor.BEGIN)) );

			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10)));

			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.LEFT, 10)));

			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.SIZE, SizeDescriptor.LENGTH | SizeDescriptor.SHORTER | SizeDescriptor.WHOLE, 4)));

			one_rel.push(new RelationDescription(1,2,new PrimitivesRelation(RelationDescriptorType.SIZE, SizeDescriptor.HEIGHT | SizeDescriptor.ABOUT_25, 10)));

			one = new ShapeModel(Character.ONE, one_prim, one_ref, one_rel, new Array(), name);
			
			return one;				
		}
		
		//---------------------------------------------------
		
		private static function getModel2():ShapeModel{
			var one:ShapeModel;
			var name:String = "MB_1OLD";
			var one_prim:Array = new Array();
			var one_ref:Array = new Array();
			var one_rel:Array = new Array();
			
			one_prim.push(PrimitiveType.LINE3,  PrimitiveType.LINE2, PrimitiveType.LINE0);
			
			one_ref.push(0,1,2,PrimitivePresets.RLT_FULL, PrimitivePresets.RLT_LOWER_QUARTER);
			
			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.CONNECTION, ConnectionsDescriptor.EXIST, 10, 
															ObjectDescriptor.END_EASTERN, ObjectDescriptor.BEGIN)) );
															
			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10)));
			
			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.LEFT, 10)));
																		
			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.SIZE, SizeDescriptor.LENGTH | SizeDescriptor.SHORTER | SizeDescriptor.HALF, 7)));
															
			one_rel.push(new RelationDescription(0,2,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10)));
			
			one_rel.push(new RelationDescription(0,2,new PrimitivesRelation(RelationDescriptorType.CONNECTION, ConnectionsDescriptor.NONE, 5)));
						
			
			one_rel.push(new RelationDescription(1,2,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10)));
			
			one_rel.push(new RelationDescription(1,2,new PrimitivesRelation(RelationDescriptorType.ANGLE, 90 | AngleDescriptor.IS_ABOUT_MARGIN_30, 5)));
			
			one_rel.push(new RelationDescription(1,3,new PrimitivesRelation(RelationDescriptorType.SIZE, SizeDescriptor.HEIGHT | SizeDescriptor.ABOUT_25, 10)));
			
			
			one_rel.push(new RelationDescription(2,3,new PrimitivesRelation(RelationDescriptorType.SIZE, SizeDescriptor.WIDTH | SizeDescriptor.ABOUT_25, 3)));
			
			one_rel.push(new RelationDescription(2,4,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.INSIDE_WHOLE, 7)));
			
			one = new ShapeModel(Character.ONE, one_prim, one_ref, one_rel, new Array(), name);
			
			return one;				
		}
		
		//---------------------------------------------------
		
		private static function getModel3():ShapeModel{
			var one:ShapeModel;
			var name:String = "MB_1CURV";
			var one_prim:Array = new Array();
			var one_ref:Array = new Array();
			var one_rel:Array = new Array();
			
			one_prim.push(PrimitiveType.CURVE_23, PrimitiveType.LINE2);
			
			one_ref.push(0,1,PrimitivePresets.RLT_FULL);
			
			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.CONNECTION, ConnectionsDescriptor.EXIST, 10, 
				ObjectDescriptor.END_EASTERN, ObjectDescriptor.BEGIN)) );
			
			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10)));
			
			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.LEFT, 10)));
			
			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.SIZE, SizeDescriptor.LENGTH | SizeDescriptor.SHORTER | SizeDescriptor.WHOLE, 4)));
			
			one_rel.push(new RelationDescription(1,2,new PrimitivesRelation(RelationDescriptorType.SIZE, SizeDescriptor.HEIGHT | SizeDescriptor.ABOUT_25, 10)));
			
			one = new ShapeModel(Character.ONE, one_prim, one_ref, one_rel, new Array(), name);
			
			return one;				
		}
		
		//---------------------------------------------------
		
		private static function getModel4():ShapeModel{
			var one:ShapeModel;
			var name:String = "MB_1LONG";
			var one_prim:Array = new Array();
			var one_ref:Array = new Array();
			var one_rel:Array = new Array();
			
			one_prim.push(PrimitiveType.LINE3,  PrimitiveType.LINE2);
			
			one_ref.push(0,1,PrimitivePresets.RLT_FULL);
			
			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.CONNECTION, ConnectionsDescriptor.EXIST, 10, 
				ObjectDescriptor.END_EASTERN, ObjectDescriptor.BEGIN)) );
						
			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.LEFT, 10)));
			
			one_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.SIZE, SizeDescriptor.HEIGHT | SizeDescriptor.IS_HIGHER_THAN_HALF, 5)));
			
			one_rel.push(new RelationDescription(1,2,new PrimitivesRelation(RelationDescriptorType.SIZE, SizeDescriptor.HEIGHT | SizeDescriptor.ABOUT_25, 10)));
			
			one = new ShapeModel(Character.ONE, one_prim, one_ref, one_rel, new Array(), name);
			
			return one;				
		}
		
	}
}